package ACMProble;

import java.io.BufferedInputStream;
import java.util.Scanner;

public class Pro2033 {
	public static void main(String[] agrs){
		Scanner in = new Scanner(new BufferedInputStream(System.in));
		while(in.hasNext()){
			int n = in.nextInt();
			int[][] time = new int[n][6];
			for(int i=0;i<n;i++){
				for(int j=0;j<6;j++){
					time[i][j] = in.nextInt();
				}
			}
			
			for(int i=0;i<n;i++){
				int[] result = new int[3];
				boolean[] flag = new boolean[]{false,false,false};
				for(int j=2;j>=0;j--){
					int data = time[i][j]+time[i][j+3];
					if(flag[j])
						data++;
					if(data>59){
						data -= 60;
						if(j>0){
							flag[j-1] = true;
						}
					}
					result[j] = data;
				}
				for(int t=0;t<3;t++){
					System.out.print(result[t]+" ");
				}
				System.out.println();
			}
		}
		in.close();
	}
	
}
